<?php
declare(strict_types=1);

namespace Service\AddressService\Volidate;

use Service\BaseService;
use App\Model\BbcModel\Member;
use Service\Code\Normal;

class AddressVolidate extends BaseService
{
    
    /**
     * 验证新增
     * @param    array $param
     * @access   protected
     * @return   array
     */
    public function validateCreate(array $param = []):array
    {
        if (empty($param['mid'])) {
            return Normal::returnCode(Normal::FAIL,'expect param mid');
        }

        $member = Member::instance()->info(['mid'=>$param['mid']]);

        if (empty($member)) {
            return Normal::returnCode(Normal::FAIL,'用户不存在');
        }

        if (empty($param['true_name'])) {
            return Normal::returnCode(Normal::FAIL,'请输入收货人');
        }

        if (empty($param['mobile'])) {
            return Normal::returnCode(Normal::FAIL,'请输入收货人手机');
        }

        if (empty($param['province'])) {
            return Normal::returnCode(Normal::FAIL,'请选择省');
        }
        if (empty($param['address'])) {
            return Normal::returnCode(Normal::FAIL,'请输入详细地址');
        }
        return Normal::returnCode(Normal::SUC,'验证通过');
    }
}